﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using System.Data.SqlClient;

namespace QUAN_LY_MUON_TRA_SACH
{
    public partial class rpt_phieu_phat : DevExpress.XtraReports.UI.XtraReport
    {
        public rpt_phieu_phat()
        {
            InitializeComponent();
        }
        public void BindData()
        {
            xlbnguoilap.Text = FORM_MAIN.frmmain.siInfo.Caption;
            SqlCommand lenh = new SqlCommand("select SOPHIEU from phieu_muon a,phieu_phat b,the_doc_gia c where a.stt_phieu=b.stt_phieu and a.mathe=c.mathe and a.mathe='" + frmphatdocgia.mathe + "' and sophieu=(select max(sophieu) from phieu_phat a,phieu_muon b where a.stt_phieu=b.stt_phieu and mathe='" + frmphatdocgia.mathe + "')", Connection.sqlConnection);
            xlbsophieu.Text = Convert.ToString(lenh.ExecuteScalar());
            lenh = new SqlCommand("select a.MATHE from phieu_muon a,phieu_phat b,the_doc_gia c where a.stt_phieu=b.stt_phieu and a.mathe=c.mathe and a.mathe='" + frmphatdocgia.mathe + "' and sophieu=(select max(sophieu) from phieu_phat a,phieu_muon b where a.stt_phieu=b.stt_phieu and mathe='" + frmphatdocgia.mathe + "')", Connection.sqlConnection);
            xlbmathe.Text = Convert.ToString(lenh.ExecuteScalar());
            lenh = new SqlCommand("select HTEN_DG from phieu_muon a,phieu_phat b,the_doc_gia c where a.stt_phieu=b.stt_phieu and a.mathe=c.mathe and a.mathe='" + frmphatdocgia.mathe + "' and sophieu=(select max(sophieu) from phieu_phat a,phieu_muon b where a.stt_phieu=b.stt_phieu and mathe='" + frmphatdocgia.mathe + "')", Connection.sqlConnection);
            xlbhoten.Text = Convert.ToString(lenh.ExecuteScalar());
            lenh = new SqlCommand("select RTRIM(CAST((DATEPART(DAY,NGAYLAP)) AS CHAR(5)))+'/'+RTRIM(CAST((DATEPART(MONTH,NGAYLAP)) AS CHAR(5)))+'/'+CAST((DATEPART(YEAR,NGAYLAP)) AS CHAR(5)) AS NGAYLAP from phieu_muon a,phieu_phat b,the_doc_gia c where a.stt_phieu=b.stt_phieu and a.mathe=c.mathe and a.mathe='" + frmphatdocgia.mathe + "' and sophieu=(select max(sophieu) from phieu_phat a,phieu_muon b where a.stt_phieu=b.stt_phieu and mathe='" + frmphatdocgia.mathe + "')", Connection.sqlConnection);
            xlbngaylap.Text = Convert.ToString(lenh.ExecuteScalar());
            lenh = new SqlCommand("select SOTIEN_PHAT from phieu_muon a,phieu_phat b,the_doc_gia c where a.stt_phieu=b.stt_phieu and a.mathe=c.mathe and a.mathe='" + frmphatdocgia.mathe + "' and sophieu=(select max(sophieu) from phieu_phat a,phieu_muon b where a.stt_phieu=b.stt_phieu and mathe='" + frmphatdocgia.mathe + "')", Connection.sqlConnection);
            xlbsotien.Text = Convert.ToString(lenh.ExecuteScalar());
            lenh = new SqlCommand("select LY_DO from phieu_muon a,phieu_phat b,the_doc_gia c where a.stt_phieu=b.stt_phieu and a.mathe=c.mathe and a.mathe='" + frmphatdocgia.mathe + "' and sophieu=(select max(sophieu) from phieu_phat a,phieu_muon b where a.stt_phieu=b.stt_phieu and mathe='" + frmphatdocgia.mathe + "')", Connection.sqlConnection);
            xlblydo.Text = Convert.ToString(lenh.ExecuteScalar());
        }
    }
}
